//microcommand define sun
const { sun } = require("@lnnbot-private/sun.js")
const INPUT_MODES = ["name", "acname", "english", "qihanzi", "digit", "letter", "order", "zheng"]
const OUTPUT_MODES = [...INPUT_MODES, "whole", "modern", "sentence", "prophecy"]
signature("<spec>", { checkUnknown: true })
for (const mode of INPUT_MODES)
  option(mode, `-${mode[0]}`, {
    descPath: "commands.sun.input-option",
    params: [[h.i18n(`commands.sun.modes.${mode}`), "\u2060"]],
  })
for (const mode of OUTPUT_MODES)
  option(`o${mode}`, `-${mode[0].toUpperCase()}`, {
    descPath: "commands.sun.output-option",
    params: [[h.i18n(`commands.sun.modes.${mode}`), "\u2060"]],
  })
action(({ session, options }, input) => {
  var inOption = ""
  for (const mode of INPUT_MODES) {
    if (options[mode]) {
      if (inOption) throw new SessionError(".no-multiple-input-modes")
      inOption = mode
    }
  }
  var outOptions = []
  if (options.owhole) outOptions = ["whole"]
  else if (options.omodern) outOptions = ["modern"]
  else outOptions = OUTPUT_MODES.filter(mode => options[`o${mode}`])
  var outstr = sun(input, inOption, outOptions)
  if (outstr === undefined) return session.i18n(".not-found")
  else return outstr
})
locale("zh-CN", {
  description: "查询太阳易卦信息",
  usage: "<br/>",
  "input-option": "输入使用{0}",
  "output-option": "输出{0}",
  modes: {
    name: "现代文卦名",
    acname: "文言文卦名",
    english: "英文卦名",
    qihanzi: "七汉字卦形",
    digit: "数字卦形",
    letter: "字母卦形",
    order: "自然序序号",
    zheng: "整序序号",
    whole: "所有卦象信息",
    modern: "现代文卦象信息",
    sentence: "现代文卦辞",
    prophecy: "文言文卦辞",
  },
  messages: {
    "no-multiple-input-modes": "输入形式不得多选…",
    "not-found": "查无此卦…",
  },
})